public class NextDate {

	public static String classify(int year, int month, int day) {	
		String nextd="";
        int dayfab=28;
        int dayusual=30;
        //闰年2月
        if((year%4==0 && year%100!=0)||(year%400==0)){
        	dayfab=29;
        }
        //有31号的月份
        if(month==1||month==3||month==5||month==7||month==8||month==10){       
        	dayusual=31;
        }
        //12月
        if(month==12){       
            if(day==31){
            	nextd=add(year+1, 1, 1);
            }   
            else if(day<dayusual){
            	nextd=add(year, month, day+1);
            }  
            else if(day>dayusual){
            	nextd="输入错误，12月只有31天！";
            } 
        }
        //2月
        else if(month==2){       
        	if(day<dayfab){
        		nextd=add(year, month, day+1);
        	}
        	if(day==dayfab){
        		nextd=add(year, month+1, 1);
        	}
        	if(day>dayfab){
        		nextd="输入错误，2月有28天或29天！";
        	}
        }
        else if(month>12 || month<1){
        	nextd="月份输入错误！";
        }
        else{
        	if(day==dayusual){
        		nextd=add(year, month+1, 1);
        	}     	
            else if(day<dayusual){
            	nextd=add(year, month, day+1);
            }      	
            else if(day>dayusual){
            	nextd="日期输入错误！";
            }        	
        }
        return nextd;
	}
	
	public static String add(int year,int month,int day ){
		String time=Integer.toString(year)+"."+Integer.toString(month)+"."+Integer.toString(day);
		return time;
  }

}
